package com.lindroy.androidplayer.ui

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ObjectAnimator
import com.lindroy.androidplayer.MainActivity
import com.lindroy.androidplayer.R
import com.lindroy.androidplayer.base.BaseActivity
import com.lindroy.lib_utils.extensions.getResColor
import com.lindroy.lib_utils.extensions.launchActivity
import com.lindroy.lib_utils.extensions.statusbar.setStatusBarColor
import com.lindroy.lib_utils.extensions.statusbar.setTransParentStatusBar
import kotlinx.android.synthetic.main.activity_splash.*

/**
 * @author Lin
 *
 * @date 2021/4/7
 * @function 闪屏页
 * @Description
 */
class SplashActivity(override val layoutId: Int = R.layout.activity_splash) : BaseActivity() {
    private lateinit var objectAnimator: ObjectAnimator

    override fun initView() {
        setStatusBarColor(getResColor(R.color.primary_dark))
        objectAnimator = ObjectAnimator.ofArgb(
            frameLayout, "backgroundColor", getResColor(R.color.primary_dark),
            getResColor(R.color.primary)
        )
        objectAnimator.duration = 1500
        objectAnimator.start()
    }

    override fun initData() {

    }

    override fun initListener() {
        objectAnimator.addListener(object : AnimatorListenerAdapter(){
            override fun onAnimationEnd(animation: Animator?) {
                super.onAnimationEnd(animation)
                launchActivity<MainActivity>()
                finish()
            }
        })
    }

    override fun initClick() {

    }
}